import { LoginAction } from './../../types/store.d'
import { Token } from './../../types/data.d'
import { getToken } from '@/utils'

const initialState: Token = getToken()

export const login = (
  state = initialState,
  action: LoginAction
): Partial<Token> => {
  if (action.type === 'login/token') {
    return action.payload
  }
  if (action.type === 'login/logout') {
    return {}
  }
  return state
}
